//相关数据结构和接口请参考 https://192.168.1.99/svn/MIDISV3/Software/trunk/public/inf/devModel
const mediaModule = {
  namespaced: true,
  state: {
    ccInfo: {
      comCnt: 0,
      irInCnt: 0,
      irOutCnt: 0,
      ioCnt: 0,
      relayCnt: 0
    },
    comInfos: [],
    irInfos: [],
    irOutInfos: [],
    hideComSetting: true,
    hideIrOutSetting: true,
    hideKvm: false,
  },
  mutations: {
    GET_CCINFO(state, res) {
      state.ccInfo = res
    },
    GET_COMINFO(state, res) {      
      if(state.comInfos[res.index]){
        if(res.hasOwnProperty('comCfg')){
          state.comInfos[res.index].comCfg = res.comCfg
        } else{
          state.comInfos[res.index].comPro = res.comPro
        }
        
      } else {
        state.comInfos[res.index] = {
          index: res.index,
          comCfg: res.comCfg || {},
          comPro: res.comPro || {}
        }
      }
    },
    GET_IROUTINFO(state, res) { 
      state.irOutInfos[res.index] = res   
    },
    HIDE_COM_SETTING(state, res) {       
      state.hideComSetting = res   
    },
    HIDE_IROUT_SETTING(state, res) { 
      state.hideIrOutSetting = res   
    },
    HIDE_KVM(state, res) { 
      state.hideKvm = res   
    },

  },
  actions: {
    getCCInfo({
      commit
    }, res) {
      commit('GET_CCINFO', res);
    },
    getComInfo({
      commit
    }, res) {
      commit('GET_COMINFO', res);
    },
    getIrOutInfo({
      commit
    }, res) {
      commit('GET_IROUTINFO', res);
    },
    hideComSetting({
      commit
    }, res) {
      commit('HIDE_COM_SETTING', res);
    },
    hideIrOutSetting({
      commit
    }, res) {
      commit('HIDE_IROUT_SETTING', res);
    },
    hideKvm({
      commit
    }, res) {
      commit('HIDE_KVM', res);
    },

  }
};

export default mediaModule
